﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Deployment.BuildManager.ExternalProcess.Common
{
    /// <summary>
    /// Classe de apoio para manipulacao de arquivos.
    /// </summary>
    public static class FileHelper
    {
        /// <summary>
        /// Remove o atributo read-only de todos os arquivos de uma pasta.
        /// </summary>
        /// <param name="currentDir"></param>
        public static void ClearAttributes(string currentDir)
        {
            DirectoryInfo dir = new DirectoryInfo(currentDir);

            List<string> files = (from d in dir.GetFiles("*.*", SearchOption.AllDirectories)
                                  select string.Concat(d.DirectoryName, Path.DirectorySeparatorChar, d.ToString())).ToList();

            foreach (string file in files)
                File.SetAttributes(file, FileAttributes.Normal);
        }
    }
}
